home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / misc / examples.pro < prev    next >
Text File  |  1997-07-08  |  5KB  |  147 lines

  1. ; $Id: examples.pro,v 1.14 1997/03/05 19:56:23 alan Exp $
  2. ;
  3. ; Copyright (c) 1995-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5. ;+
  6. ; NAME: Examples
  7. ;
  8. ; PURPOSE: This widget application guides the user through the IDL 
  9. ;          family of technical widget programming examples.
  10. ;
  11. ; MAJOR TOPICS: Launching widget applications.
  12. ;
  13. ; CALLING SEQUENCE: Examples
  14. ;
  15. ; PROCEDURE: Examples ...
  16. ;
  17. ; MAJOR FUNCTIONS and PROCEDURES:
  18. ;
  19. ; MODIFICATION HISTORY:  Written by:  WSO, RSI, January 1995
  20. ;-
  21.  
  22. PRO ExamplesEventHdlr, event
  23.  
  24. ; This is the event processing routine that takes care of the events being
  25. ; sent to it from the XManager.
  26.  
  27.    WIDGET_CONTROL, GET_UVALUE=control, event.id
  28.  
  29.    CASE control OF
  30.  
  31.      "INFO": BEGIN
  32.  
  33.          infoText = [ $
  34.           "This application shows some of the capabilities of IDL using "+ $
  35.           "widgets.  Each section shows ways "+ $
  36.           "IDL can be used to easily view data using widgets as the "+ $
  37.           "user interface. ", "", $
  38.           'The "Examples" pull-down menu contains a menu item for each '+ $
  39.           "widget application example. ", "", $
  40.           "The data in this file has all been gathered from people "+ $
  41.           "using IDL or has been generated using IDL.  For more "+ $
  42.           "information on the data in each example select the info... button "+ $
  43.           "option in that example to learn more. ", "", $
  44.           "All computations are performed on your workstation as "+ $
  45.           "you watch.  The source code for all examples and "+ $
  46.           "computations is contained in the $IDL_DIR/examples directory "+ $
  47.           "tree.  All user interfaces and computations are "+ $
  48.           "programmed using only standard IDL.  No displays or "+ $
  49.           "visualizations are pre-computed.  Only one IDL process is "+ $
  50.           "active."]
  51.  
  52.          ShowInfo, TITLE="Examples Information", GROUP=event.top, $
  53.            WIDTH=80, HEIGHT=24, INFOTEXT=infoText
  54.       ENDCASE
  55.  
  56.      "EXIT": WIDGET_CONTROL, event.top, /DESTROY
  57.     
  58.         ; User selected an item from the Examples menu - 
  59.         ; execute the proper procedure that was stored in the user value 
  60.         ; for each menu item.
  61.       ELSE:  returnValue = EXECUTE(control + ', GROUP=event.top')
  62.  
  63.    ENDCASE
  64. END
  65.  
  66.  
  67. PRO CleanUpExamples, wExamplesWindow
  68.  
  69.      ; Get the color table saved in the window's user value
  70.    WIDGET_CONTROL, wExamplesWindow, GET_UVALUE=colorTable
  71.    
  72.      ; Restore the previous color table.
  73.    TVLCT, colorTable
  74.  
  75. END
  76.  
  77.  
  78. PRO Examples
  79.  
  80. ; This is the main program that creates the widgets for the examples and then 
  81. ; registers it with the xmanager.
  82.  
  83.    swin = !D.WINDOW        ; Save current window
  84.  
  85.      ; Get the current color vectors to restore when this application is exited.
  86.    TVLCT, savedR, savedG, savedB, /GET
  87.      ; Build color table from color vectors
  88.    colorTable = [[savedR],[savedG],[savedB]]
  89.    
  90.      ; Create a non-sizeable window for the Examples widget application
  91.    wExamplesWindow = WIDGET_BASE(TITLE="IDL Examples", MBAR=wMenuBar, TLB_FRAME_ATTR=1)
  92.  
  93.    ; Setting the managed attribute indicates our intention to put this app
  94.    ; under the control of XMANAGER, and prevents our draw widgets from
  95.    ; becoming candidates for becoming the default window on WSET, -1. XMANAGER
  96.    ; sets this, but doing it here prevents our own WSETs at startup from
  97.    ; having that problem.
  98.    WIDGET_CONTROL, /MANAGED, wExamplesWindow
  99.  
  100.    wExamplesBase = WIDGET_BASE(wExamplesWindow, /COLUMN)
  101.  
  102.    wFileMenu = WIDGET_BUTTON(wMenuBar, VALUE='File', /MENU)
  103.    wExitItem = WIDGET_BUTTON(wFileMenu, VALUE='Exit Examples', UVALUE='EXIT')
  104.  
  105.    wExamplesMenu = WIDGET_BUTTON(wMenuBar, VALUE='Examples', /MENU)
  106.    wExamplesItem = WIDGET_BUTTON(wExamplesMenu, VALUE='Line Drawing...', UVALUE='SPIRO')
  107.    wExamplesItem = WIDGET_BUTTON(wExamplesMenu, VALUE='Surface Drawing...', UVALUE='SPRING')
  108.    wExamplesItem = WIDGET_BUTTON(wExamplesMenu, VALUE='Text Editing...', UVALUE='EDITOR')
  109.  
  110.    wHelpMenu = WIDGET_BUTTON(wMenuBar, VALUE='Help', /HELP, /MENU)
  111.    wInfoItem = WIDGET_BUTTON(wHelpMenu, VALUE='Examples Info...', UVALUE='INFO')
  112.  
  113.      ; Read the logo for the Examples window draw widget
  114.    logo = TIFF_READ(FILEPATH("examples.tif", SUBDIRECTORY = ["examples","data"]), $
  115.                     logoR, logoG, logoB, ORDER=order)
  116.                     
  117.      ; Get the dimensions of the logo in order to create the draw widget
  118.    logoSize = SIZE(logo)
  119.    
  120.      ; Create the draw widget to match the size of the logo TIFF image
  121.    wLogo = WIDGET_DRAW(wExamplesBase, XSIZE = logoSize[1], YSIZE = logoSize[2], RETAIN = 2)
  122.    
  123.      ; Make the window visible
  124.    WIDGET_CONTROL, /REALIZE, wExamplesWindow
  125.    
  126.      ; Set cursor to arrow cursor
  127.    DEVICE, /CURSOR_ORIGINAL
  128.    
  129.      ; Save the previous color table in the user value to retore on exit ("CleanUpExamples") 
  130.    WIDGET_CONTROL, wExamplesWindow, SET_UVALUE=colorTable
  131.    
  132.      ; Display the wait cursor
  133.    WIDGET_CONTROL, wExamplesWindow, /HOURGLASS
  134.  
  135.       ; Load the needed colors for the logo
  136.    TVLCT, logoR, logoG, logoB
  137.       
  138.    ; Display the logo in the draw widget
  139.    TV, logo, ORDER=order
  140.  
  141.    WSET, swin
  142.  
  143.      ; Register this application with the xmanager
  144.    XManager, "examples", wExamplesWindow, EVENT_HANDLER="ExamplesEventHdlr", $
  145.       CLEANUP="CleanUpExamples", /NO_BLOCK
  146. END
  147.